
#include <gfx/imesh.h>
#include <gfx/material.h>
#include <scene/geometry.h>
#include <assert.h>

ceGeometry::ceGeometry(iMesh *mesh, ceMaterial *material)
  : _mesh (0)
  , _material (0)
{
  SetMesh(mesh);
  SetMaterial(material);
  CE_OBJECT_CONSTR
}

ceGeometry::~ceGeometry()
{
  CE_UNSET(_mesh);
  CE_UNSET(_material);
}

void ceGeometry::SetMesh(iMesh *mesh)
{
  CE_SET(_mesh, mesh);
}

iMesh* ceGeometry::GetMesh()
{
  return _mesh;
}

const iMesh* ceGeometry::GetMesh() const
{
  return _mesh;
}

void ceGeometry::SetMaterial(ceMaterial *material)
{
  CE_SET(_material, material);
}

ceMaterial* ceGeometry::GetMaterial()
{
  return _material;
}

const ceMaterial* ceGeometry::GetMaterial() const
{
  return _material;
}

const ceBoundingBox& ceGeometry::GetBoundingBox() const
{
  assert (_mesh);

  return _mesh->GetBoundingBox();
}

void ceGeometry::Update(const ceRenderEnvironment &env, iDevice* device)
{
  if (_mesh)
    {
      _mesh->Update(env, device);
    }
}

